# coding=utf-8
import arcpy
import os
import sys

p = arcpy.mp.ArcGISProject(
    r"D:\BaiduNetdiskWorkspace\德安县土规延续和控规调整\德安县土规延续和控规调整.aprx")
l = p.listLayouts()[0]


def files_name(dirpath):
    for root, dirs, files in os.walk(dirpath):
        return files
namelist = files_name(r"D:\\BaiduNetdiskWorkspace\\德安县项目附图\\三线图")

if not l.mapSeries is None:
    ms = l.mapSeries
    if ms.enabled:
        for pageNum in range(1, ms.pageCount + 1):
            ms.currentPageNumber = pageNum
            pageName = ms.pageRow.项目名称+".png"
            if pageName not in namelist:
                l.exportToPNG(r"D:\\BaiduNetdiskWorkspace\\德安县项目附图\\影像图\\" +
                            pageName, resolution=100)
                print("Exporting {0}".format(pageName))

